import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-01-20
 * Time:9:16
 */
public class Test{
    public void InsertSort(Comparable[] array) {
        for(int i = 0;i < array.length - 1;++i) {
            for(int j = i;j>=0;--j) {
                if(array[j].compareTo(array[j+1]) > 0) {
                    Comparable tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                }
            }
        }
    }


    public static void main(String[] args) {
        Student students[] = new Student[]{
                new Student("张三", 98),
                new Student("李四", 99),
                new Student("王五", 85),
                new Student("Sugar", 88)
        };
        InsertSort(students);

        for (Student student:students) {
            System.out.println(student);
        }
    }

}


